let app = getApp()
let request = require("../../../utils/request.js")
let upload = require("../../../utils/upload.js")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: app.globalData.statusBarHeight,
    screenHeight: app.globalData.screenHeight,
    reasonVal: '',
    verifyLoginDialog: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let token = wx.getStorageSync('token');
    if (!token) {
      this.setData({
        verifyLoginDialog: true
      })
    }
  },

  refundMessage(e) {
    this.setData({
      reasonVal: e.detail.value
    })
  },
  /**
   * 返回上一页面
  */
  back(){
    wx.navigateBack({
      delta: 1
    });
  },
//提交
  submitMsg() {
    let that = this
    if (!this.data.reasonVal) {
      wx.showToast({
        title: '请填写问题描述及建议',
        icon: 'none'
      })
      return
    }
    let parmas = {
      feedbackContent: this.data.reasonVal
    }
    request.http('/customer/feedback/add', 'POST', parmas, 0)
      .then(res => {
        if (res.data.code == 200) {
          let data = res.data.data
          wx.showToast({
            title: '提交成功',
            duration: 2000,
            success:function(){
              setTimeout(function () {
                that.back();
              }, 2000) 
            }
          })
        }
      })
  },
  
  
})